package BasicGrammar.Basic;

import java.util.Arrays;

public class day_0920 {

    public static void main(String[] args) {
        int[] a = {1,2,3,4,5};

        String ret = reveres(a);
        System.out.println(ret);
    }

        public static String reveres(int[] a){

            int i = 0;
            int j = a.length-1;
//            while(i < j){
//                x = a[i];
//                a[i] = a[j];
//                a[j] = x;
//                i++;
//                j--;
//            }

            int[] b = swap(a,i,j);

            return Arrays.toString(b);
        }

        public  static int[] swap(int[] a,int i,int j){
            int x= 0;
            while(i < j){
                x = a[i];
                a[i] = a[j];
                a[j] = x;
                i++;
                j--;
            }
            return a;
        }

    public static String my(int[] a){
        String ret = "[";
        int i=0;
        for(i = 0;i < (a.length);i++){
            ret += a[i] + ",";
        }

        ret += "]";
        return ret;
    }

    public static void main3(String[] args) {
        int[] a = {1,2,3,4,5};
        String si = my(a);
        System.out.println(si);
    }

    public static void main1(String[] args) {
        int[] a = {1,2,3,4,5};
        int[] b = new int[]{1,2,3,4};
        int[] c = new int[4];
//        c = int[]{1,2,3,4};
        //前置与后置（int[]）(new)有一个即可，但不可缺

//        for (int i = 0; i < a.length; i++) {
//            System.out.print(a[i]);
//        }
//
//        for(int x : a){
//            System.out.println(x);
//        }
//增强for循环：轮流赋值x

        String ret = Arrays.toString(a);
        System.out.println(ret);



        //null

        fu(a);
        System.out.println(Arrays.toString(a));

//        System.out.println(a);
        System.out.println(a[4]);
    }
    public static void fu(int[] a){
        a = new int[]{10,90,89,99,87};
    }

    public static void fu2(int[] a){
        a = new int[]{10,90,89,99,87,56};
    }

//    public static void main1(String[] args) {
//        Scanner sc = new Scanner(System.in);
//
//        int a =sc.nextInt();
//
//        System.out.println((a));
//    }
}
